#ifndef CLIENTMANAGER_H
#define CLIENTMANAGER_H

#include <QMutex>
#include <QList>
#include <QByteArray>

class TaskRunnable;
class ClientManager
{
public:
    /**
     * @brief 单例
     * @return
     */
    static ClientManager & getInstance();

    /**
     * @brief addTask
     * @param task
     */
    void addTask(TaskRunnable * task);


    /**
     * @brief 删除一个任务
     * @param task
     */
    void removeOne(TaskRunnable * task);

    /**
     * @brief sendData
     * @param arr
     */
    void sendData(const QByteArray &arr);


    /**
     * @brief 客户端个数
     * @return
     */
    int clientCount();

    /**
     * @brief 关闭所有客户端
     */
    void closeAllClients();

private:
    ClientManager(){}
    Q_DISABLE_COPY(ClientManager);

private:
    static ClientManager * m_instance;
    static QMutex m_mutex;

   QList<TaskRunnable *> m_clientList;

};

#endif // CLIENTMANAGER_H
